using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using JGSY.CMS.LowCode.Platform.Domain.Interfaces;

namespace JGSY.CMS.LowCode.Platform.Domain.Entities
{
    /// <summary>
    /// 内容项实体
    /// 表示基于内容模型创建的具体内容实例
    /// </summary>
    [Table("content_items")]
    public class ContentItem : ITenantEntity
    {
        /// <summary>
        /// 内容项标识符
        /// </summary>
        [Key]
        public long Id { get; set; }
        
        /// <summary>
        /// 标题
        /// 内容项的显示标题
        /// </summary>
        [Required]
        [StringLength(255)]
        public string Title { get; set; } = string.Empty;
        
        /// <summary>
        /// 数据内容
        /// 以JSON格式存储的结构化内容数据
        /// </summary>
        [Column(TypeName = "json")]
        public string Data { get; set; } = string.Empty;
        
        /// <summary>
        /// 发布状态
        /// 如：草稿(draft)、已发布(published)、已撤回(withdrawn)等
        /// </summary>
        [StringLength(50)]
        public string Status { get; set; } = "draft";
        
        /// <summary>
        /// 内容模型标识符
        /// 关联的内容模型ID
        /// </summary>
        [Required]
        public long ModelId { get; set; }
        
        /// <summary>
        /// 关联的内容模型
        /// 导航属性，指向该内容项对应的模型定义
        /// </summary>
        [ForeignKey(nameof(ModelId))]
        public ContentModel? Model { get; set; }
        
        /// <summary>
        /// 创建时间
        /// 内容项的创建时间戳
        /// </summary>
        public DateTime CreatedAt { get; set; }
        
        /// <summary>
        /// 更新时间
        /// 内容项的最后修改时间戳
        /// </summary>
        public DateTime UpdatedAt { get; set; }
        
        /// <summary>
        /// 租户标识符
        /// </summary>
        public string TenantId { get; set; } = string.Empty;
    }
}
